<template>
  <div class="div">        
    <div class="div_right">
      <a-empty :description="false" />
    </div>
  </div>
</template>

<script>
import login from '../api/login'
export default {
  data() {
    return {
      user:{},
      confirms:'',
    };
  },
  methods:{
    // 查询当前用户
    getlonin(){
      login.danglogin().then(res=>{
        if(res.data.code === 20000){
          this.user = res.data.user
          this.iflonin(this.user.userId)
        }
      })
      .catch((error) => {
        console.log(error.message)
        // console.log(toString(error.message))
        if(error.message == "Network Error"){
          localStorage.clear()
        }
      });
    },
    // 判断是否是新用户
    iflonin(userId){
      // console.log(userId)
      login.iflogin(userId).then(res=>{
        if(res.data.code === 20000){
          console.log("欢迎使用")
        }else if (res.data.code === 500){
          this.confirms = confirm("检测到你是新用户，请修改密码")
          if(this.confirms){
            this.$router.push('/management?name=用户资料&user=1');
          }
        }
      })
    }
  },
  created(){
    this.getlonin()
  }
};
</script>